import request from '@/config/axios'

export interface OrderWithdrawalVO {
  id: number
  orderNo: string
  guestName: string
  roomType: string
  plannedCheckIn: Date
  plannedCheckOut: Date
  actualNights: number
  actualCheckoutDate: localdate
  amountPaid: number
  refundAmount: number
  amountReceived: number
  platformCommission: number
  settlementAmount: number
  withdrawStatus: number
  createdAt: Date
  updatedAt: Date
}

// 查询订单提现分页
export const getOrderWithdrawalPage = async (params) => {
  return await request.get({ url: `/hotel/order-withdrawal/page`, params })
}

// 查询订单提现详情
export const getOrderWithdrawal = async (id: number) => {
  return await request.get({ url: `/hotel/order-withdrawal/get?id=` + id })
}

// 新增订单提现
export const createOrderWithdrawal = async (data: OrderWithdrawalVO) => {
  return await request.post({ url: `/hotel/order-withdrawal/create`, data })
}

// 修改订单提现
export const updateOrderWithdrawal = async (data: OrderWithdrawalVO) => {
  return await request.put({ url: `/hotel/order-withdrawal/update`, data })
}

// 删除订单提现
export const deleteOrderWithdrawal = async (id: number) => {
  return await request.delete({ url: `/hotel/order-withdrawal/delete?id=` + id })
}

// 导出订单提现 Excel
export const exportOrderWithdrawal = async (params) => {
  return await request.download({ url: `/hotel/order-withdrawal/export-excel`, params })
}

export const getFinancialDashboard=async () => {
  return await request.get( {url: '/hotel/order-withdrawal/getFinancialDashboard'});
}

export const handleWithdraw = async (orderNo: string) => {
  return await request.post(
    {
      url: '/hotel/order-withdrawal/handleWithdraw',
      params: {orderNo}
    });
}

export const batchWithdraw = async (orderNos: string[]) => {
  return await request.post({
    url: '/hotel/order-withdrawal/batchWithdraw',
    data: {'orderNos':orderNos}
  });
}